<template>
  <base-breadcrumb title="科技成果详情" :breadcrumb="!isAudit">
    <div v-loading="loading" class="about-master-container">
      <a-card>
        <title-name title="基础信息" />
        <a-form-model>
         <a-row>
            <a-col span="8">
              <a-form-model-item label="所属分公司">
                <BaseInput disabled v-model="form.branchCompanyName" placeholder="请输入" />
              </a-form-model-item>
            </a-col>
            <a-col span="8">
              <a-form-model-item label="项目名称">
                <BaseInput disabled v-model="form.projectName" placeholder="请输入" />
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </a-card>
      <a-card>
        <title-name title="科技成果完成情况" />
        <a-form-model>
          <a-row>
            <a-col span="8">
              <a-form-model-item label="完成状态">
                <BaseInput disabled value="获得" />
              </a-form-model-item>
            </a-col>
            <a-col span="8">
              <a-form-model-item label="完成成果名称">
                <BaseInput disabled v-model.trim="form.achievementName" placeholder="请输入完成成果名称" />
              </a-form-model-item>
            </a-col>
            <a-col span="8">
              <a-form-model-item label="成果分类">
                <BaseInput disabled v-model="form.achievementClassify" />
              </a-form-model-item>
            </a-col>
            <a-col span="8" v-if="form.paper">
              <a-form-model-item label="期刊类型">
                <BaseInput v-if="form.paper" disabled v-model="form.paper.periodicalTypeName" />
              </a-form-model-item>
            </a-col>
            <a-col span="8">
              <a-form-model-item label="成果等级">
                <BaseInput disabled v-model="form.achievementLevel" />
              </a-form-model-item>
            </a-col>
            <a-col span="16">
              <a-form-model-item label="完成人">
                <a-tag v-for="(item, index) in form.completeNames" :key="index">
                  {{ item }}
                </a-tag>
                <span v-if="!form.completeNames">无</span>
                <span class="del_btn mr20">（按证书上面完成人顺序填写）</span>
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row>
            <a-col span="8">
              <a-form-model-item label="完成日期">
                <BaseInput disabled v-model="form.gainTime" />
              </a-form-model-item>
            </a-col>
            <a-col span="8">
              <a-form-model-item label="标引">
                <BaseInput disabled v-model="form.indexing" />
              </a-form-model-item>
            </a-col>
          </a-row>
          <a-row>
            <template v-if="achievementsTypeName === '科技奖'">
              <a-col span="8">
                <a-form-model-item label="授奖称号">
                  <BaseInput disabled :value="form.technology ? form.technology.awardTitle : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="授奖单位">
                  <BaseInput disabled :value="form.technology ? form.technology.awardUnit : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="成果完成单位">
                  <BaseInput disabled :value="form.technology ? form.technology.completeUnit : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="证书编号">
                  <BaseInput disabled :value="form.technology ? form.technology.certificateNo : void 0" />
                </a-form-model-item>
              </a-col>
            </template>

            <!--                研发立项-->
            <template v-if="achievementsTypeName === '研发立项'">
              <a-col span="8">
                <a-form-model-item label="立项编号">
                  <BaseInput disabled :value="form.project ? form.project.projectNumber : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="实施情况">
                  <BaseInput disabled :value="form.project ? form.project.implementation : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="起始时间">
                  <BaseInput disabled :value="form.project ? form.project.startTime : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="计划验收时间">
                  <BaseInput disabled :value="form.project ? form.project.planAcceptanceTime : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="实际验收时间">
                  <BaseInput disabled :value="form.project ? form.project.actualAcceptanceTime : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="总经费（万）">
                  <BaseInput disabled :value="form.project ? form.project.totalMoney : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="资助经费（万）">
                  <BaseInput disabled :value="form.project ? form.project.subsidizeMoney : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="课题负责人">
                  <BaseInput disabled :value="form.project ? form.project.classPrincipalPeople : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="证书编号">
                  <BaseInput disabled :value="form.project ? form.project.certificateNo : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="课题研发人员">
                  <BaseInput disabled :value="form.project ? form.project.classDiscoveryPeople : void 0" />
                </a-form-model-item>
              </a-col>
            </template>

            <!--                示范工程立项-->
            <template v-if="achievementsTypeName === '示范工程立项'">
              <a-col span="8">
                <a-form-model-item prop="projectCode" label="立项编号">
                  <BaseInput disabled :value="form.demonstration ? form.demonstration.projectNumber : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="实施情况">
                  <BaseInput disabled :value="form.demonstration ? form.demonstration.implementation : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="实施状态">
                  <BaseInput disabled :value="form.demonstration ? form.demonstration.implementationStatus : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item prop="planDate" label="计划验收时间">
                  <BaseInput disabled :value="form.demonstration ? form.demonstration.planAcceptanceTime : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="实际验收时间">
                  <BaseInput disabled :value="form.demonstration ? form.demonstration.actualAcceptanceTime : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item prop="projectOrg" label="立项机构">
                  <BaseInput disabled :value="form.demonstration ? form.demonstration.projectOrganization : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item prop="projectLevel" label="立项级别">
                  <BaseInput disabled :value="form.demonstration ? form.demonstration.projectLevel : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item prop="projectPrincipalPeople" label="项目负责人">
                  <BaseInput disabled :value="form.demonstration ? form.demonstration.projectLeder : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="主要推广人员" :key="Date.now()">
                  <BaseInput disabled :value="form.demonstration ? form.demonstration.majorPromotePeople : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="地点">
                  <BaseInput disabled :value="form.demonstration ? form.demonstration.place : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="计划开竣工时间">
                  <BaseInput disabled :value="form.demonstration ? form.demonstration.planStartAndEndTime : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="规模">
                  <BaseInput disabled :value="form.demonstration ? form.demonstration.scale : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="证书编号" :key="3">
                  <BaseInput disabled :value="form.demonstration ? form.demonstration.certificateNo : void 0" />
                </a-form-model-item>
              </a-col>
            </template>

            <!--                工法-->
            <template v-if="achievementsTypeName === '工法'">
              <a-col span="8">
                <a-form-model-item label="工法编号">
                  <BaseInput disabled :value="form.method ? form.method.methodNo : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="年度">
                  <BaseInput disabled :value="form.method ? form.method.year : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="授予单位">
                  <BaseInput disabled :value="form.method ? form.method.awardUnit : void 0" />
                </a-form-model-item>
              </a-col>
            </template>

            <!--                国家知识产权-专利-->
            <template v-if="completeAchievementsLevelName === '发明专利' || completeAchievementsLevelName === '实用新型专利'">
              <a-col span="8">
                <a-form-model-item label="专利号">
                  <BaseInput disabled :value="form.patent ? form.patent.patentNo : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="申请日">
                  <BaseInput disabled :value="form.patent ? form.patent.applyDay : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="公告日">
                  <BaseInput disabled :value="form.patent ? form.patent.announcementDay : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="片区">
                  <BaseInput disabled :value="form.patent ? form.patent.zone : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="状态">
                  <BaseInput disabled :value="form.patent ? form.patent.status : void 0" />
                </a-form-model-item>
              </a-col>
            </template>

            <!--                国家知识产权-软著-->
            <template v-if="completeAchievementsLevelName === '计算机软件著作权'">
              <a-col span="8">
                <a-form-model-item label="登记号">
                  <BaseInput disabled :value="form.soft ? form.soft.registerNo : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="开发完成日">
                  <BaseInput disabled :value="form.soft ? form.soft.developmentCompletedDay : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="首次发表日">
                  <BaseInput disabled :value="form.soft ? form.soft.publicationDay : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="权利取得方式">
                  <BaseInput disabled :value="form.soft ? form.soft.wayOfPower : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="片区">
                  <BaseInput disabled :value="form.soft ? form.soft.zone : void 0" />
                </a-form-model-item>
              </a-col>
            </template>

            <!--                论文-->
            <template v-if="achievementsTypeName === '论文'">
              <a-col span="8">
                <a-form-model-item label="刊物">
                  <BaseInput disabled :value="form.paper ? form.paper.publication : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="年度">
                  <BaseInput disabled :value="form.paper ? form.paper.year : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="期数">
                  <BaseInput disabled :value="form.paper ? form.paper.periods : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="论文情况">
                  <BaseInput disabled :value="form.paper ? form.paper.paperSituation : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="第一作者职称">
                  <BaseInput disabled :value="form.paper ? form.paper.leadAuthorJobTitle : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="第一作者职务">
                  <BaseInput disabled :value="form.paper ? form.paper.leadAuthorPosition : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="第一作者专业">
                  <BaseInput disabled :value="form.paper ? form.paper.leadAuthorSpecialty : void 0" />
                </a-form-model-item>
              </a-col>
            </template>

            <!--            科技成果评价-->
            <template v-if="achievementsTypeName.indexOf('科技成果评价') > -1">
              <a-col span="8">
                <a-form-model-item label="鉴定（验收）年月">
                  <BaseInput disabled :value="form.evaluate ? form.evaluate.appraiseDate : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="主持机构">
                  <BaseInput disabled :value="form.evaluate ? form.evaluate.presideAgency : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="24">
                <a-form-model-item label="鉴定（验收）结论摘要">
                  <BaseInput disabled :value="form.evaluate ? form.evaluate.appraiseSummary : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="鉴定（验收）主要成员">
                  <BaseInput disabled :value="form.evaluate ? form.evaluate.appraiseMember : void 0" />
                </a-form-model-item>
              </a-col>
            </template>

            <!--            科技查新-->
            <template v-if="achievementsTypeName === '科技查新'">
              <a-col span="8">
                <a-form-model-item label="委托时间">
                  <BaseInput disabled :value="form.noveltySearch ? form.noveltySearch.commissionDate : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="报告编号">
                  <BaseInput disabled :value="form.noveltySearch ? form.noveltySearch.reportCode : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="8">
                <a-form-model-item label="查新机构">
                  <BaseInput disabled :value="form.noveltySearch ? form.noveltySearch.newAgency : void 0" />
                </a-form-model-item>
              </a-col>
              <a-col span="24">
                <a-form-model-item label="查新目的">
                  <BaseInput disabled :value="form.noveltySearch ? form.noveltySearch.findPurpose : void 0" />
                </a-form-model-item>
              </a-col>
            </template>

            <a-col span="8" v-if="achievementsTypeName !== '科技奖'">
              <a-form-model-item prop="completeOrgName" label="成果完成单位">
                <!-- <BaseInput disabled :value="form.completeUnit" /> -->
                <a-tag v-for="(item, index) in form.completeUnit" :key="index">
                  {{ item }}
                </a-tag>
              </a-form-model-item>
            </a-col>
            <a-col span="16">
              <a-form-model-item label="备注">
                <BaseInput disabled :value="form.remark" />
              </a-form-model-item>
            </a-col>
            <a-col span="24">
              <a-form-model-item label="附件上传">
                <lTable v-if="type == 'edit'" businessCode="STM04" :uploadArrys.sync="form.fileList"></lTable>
                <FileLink v-else :fileList="form.fileList" />
              </a-form-model-item>
            </a-col>
          </a-row>
        </a-form-model>
      </a-card>
      <div class="pull-right page-btn-right-top">
        <a-button v-if="type === 'edit'" type="primary" @click="handleSubmit"> 提交 </a-button>
        <a-button v-check-visible-in-detail style="margin: 0 10px" @click="$close"> 关闭 </a-button>
      </div>
    </div>
  </base-breadcrumb>
</template>

<script>
import { queryAchievementsLedgerDetail, importFile } from '@/api/achievementsManage'
import BaseEditPage from '@/views/baseEditPage'

export default {
  extends: new BaseEditPage(),
  props: {
    idType: [Number, String],
    isAudit: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
      queryParam: {
        beginAndEndTime: '',
        completionStatus: '4',
        completeEmployee: [],
        indexInfo: [],
        awardingUnit: '',
        achievementsNo: ''
      },
      completeOrgList: [
        { name: '中国建筑第八工程局有限公司', id: '1' },
        { name: '中国建筑第八工程局有限公司西南分公司', id: '2' },
        { name: '中建八局西南建设工程有限公司', id: '3' },
        { name: '中建八局两江建设工程有限公司', id: '4' },
        { name: '中建八局中南建设工程有限公司', id: '5' }
      ],
      form: {
        viewName: ""
      },
      loading: false,
      disabled: false,
      achievementsTypeName: '',
      completeAchievementsLevelName: ''
    }
  },
  created() {
    // 合并链接参数到data中
    Object.assign(this.queryParam, this.$route.query)
  },
  mounted() {
    // 请求详情
    this.getData()
  },
  methods: {
    /**
     * @description: 请求详情
     */
    async getData() {
      const ID = this.id
      this.spinning = true
      this.loading = true
      let res = await queryAchievementsLedgerDetail(ID)
      this.loading = false
      if (res.code === this.SUCCESS_CODE) {
        this.achievementsTypeName = res.data?.achievementClassify
        this.completeAchievementsLevelName = res.data?.achievementLevel
        res.data.completeNames = res.data.completeName?.split(',')
        this.form = res.data
        this.form.viewName = this.form.branchCompanyName + "/" + this.form.projectName
        this.form.completeUnit = this.form.completeUnit.split(',')
      }
    },
    /**
     * @description: 提交
     */
    handleSubmit() {
      if (!this.form.fileList?.length === 0) {
        this.$message.warning('请上传附件')
        return
      }
      this.$confirm({
        title: '提示',
        content: '确定提交吗？',
        onOk: async () => {
          let res = await importFile({ businessId: this.id, fileList: this.form.fileList })
          if (res.data.code === '0') {
            this.$message.success('提交成功')
            this.$close()
          }
        }
      })
    }
  }
}
</script>
